<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function add_drawing_comment($object_id, $user_id, $comment) {
    if(!$object_id || !$user_id || !$comment || strlen($comment) <= 0)
        return FALSE;
    $timestamp = time();
    $query = "INSERT INTO drawing_comments (object_id, user_id, comment, timestamp)
                VALUES ('$object_id', '$user_id', '$comment', '$timestamp')";
    
    return safe_insert_query($query);
}

function get_drawing_comment($id) {
    $query = "SELECT object_id, user_id, comment, timestamp FROM drawing_comments WHERE id = '$id'";
}

function get_drawing_comments_of($user_id) {
    $query = "SELECT id, object_id, comment, timestamp FROM drawing_comments WHERE user_id = '$user_id'";
}

function get_drawing_comments_on($object_id) {
    $query = "SELECT id, user_id, comment, timestamp FROM drawing_comments WHERE object_id = '$object_id'";
    return safe_select_query($query);
}

function get_drawing_comment_ids($object_id, $user_id) {
    $query = "SELECT id FROM drawing_comments WHERE object_id = '$object_id' AND user_id = '$user_id'";
}

function count_drawing_comment($object_id) {
    // $object_id is a rating ID
    $query = "SELECT count(id) as count_comment FROM drawing_comments WHERE object_id = '$object_id'";
    //echo $query;
    $result = safe_select_query($query);
    //print_r($result);
    //print_r($result[0]->count_comment);
    return $result[0]->count_comment;
}

?>
